import {
  createRouter,
  createWebHistory,
  createWebHashHistory,
} from "vue-router";
import type { RouteRecordRaw } from "vue-router";
import NotFound from "@/views/404/index.vue";
const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    redirect: "/cityData",
  },
  {
    path: "/home",
    name: "home",
    component: () => import("@/views/screen/index.vue"),
    children: [
      {
        path: "/cityData",
        name: "cityData",
        component: () => import("@/views/screen/cityData/index.vue"),
      },
      {
        path: "/resultData",
        name: "resultData",
        component: () => import("@/views/screen/resultData/index.vue"),
      },
      {
        path: "/fileUpload",
        name: "fileUpload",
        component: () => import("@/views/screen/fileUpload/index.vue"),
      },
    ],
  },
  //预置的管理端页面路由
  {
    path: "/manage",
    redirect: "/manage/user",
    children: [
      {
        path: "/manage/user",
        name: "manageUser",
        component: () => import("@/views/manage/user/index.vue"),
      },
      {
        path: "/manage/roles",
        name: "manageRoles",
        component: () => import("@/views/manage/roles/index.vue"),
      },
    ],
  },
  { path: "/:pathMatch(.*)*", name: "NotFound", component: NotFound },
];
const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes,
});

router.beforeEach((to, from, next) => {
  next();
});

export default router;
